home *** CD-ROM | disk | FTP | other *** search
- head 5.7;
- branch 5.7.0;
- access;
- symbols
- RELEASE:5.7.0.7
- BETA:5.7.0.7
- UICSO:5.7.0
- VANILLA:5.7;
- locks; strict;
- comment @ * @;
-
-
- 5.7
- date 90.06.20.08.35.57; author paul; state Exp;
- branches
- 5.7.0.1;
- next ;
-
- 5.7.0.1
- date 90.06.20.09.43.04; author paul; state Exp;
- branches;
- next 5.7.0.2;
-
- 5.7.0.2
- date 90.10.13.18.40.00; author paul; state Exp;
- branches;
- next 5.7.0.3;
-
- 5.7.0.3
- date 91.02.17.02.39.09; author paul; state Exp;
- branches;
- next 5.7.0.4;
-
- 5.7.0.4
- date 91.03.04.21.48.23; author paul; state Exp;
- branches;
- next 5.7.0.5;
-
- 5.7.0.5
- date 91.04.05.14.55.15; author paul; state Exp;
- branches;
- next 5.7.0.6;
-
- 5.7.0.6
- date 91.05.18.17.29.02; author paul; state Exp;
- branches;
- next 5.7.0.7;
-
- 5.7.0.7
- date 91.05.20.02.40.07; author paul; state Exp;
- branches;
- next ;
-
-
- desc
- @@
-
-
-
- 5.7
- log
- @5.64 Berkeley release
- @
- text
- @/*
- * Copyright (c) 1983 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement: ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
- #ifndef lint
- static char sccsid[] = "@@(#)macro.c 5.7 (Berkeley) 6/1/90";
- #endif /* not lint */
-
- # include "sendmail.h"
-
- /*
- ** EXPAND -- macro expand a string using $x escapes.
- **
- ** Parameters:
- ** s -- the string to expand.
- ** buf -- the place to put the expansion.
- ** buflim -- the buffer limit, i.e., the address
- ** of the last usable position in buf.
- ** e -- envelope in which to work.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** none.
- */
-
- expand(s, buf, buflim, e)
- register char *s;
- register char *buf;
- char *buflim;
- register ENVELOPE *e;
- {
- register char *xp;
- register char *q;
- bool skipping; /* set if conditionally skipping output */
- bool recurse = FALSE; /* set if recursion required */
- int i;
- char xbuf[BUFSIZ];
- extern char *macvalue();
-
- if (tTd(35, 24))
- {
- printf("expand(");
- xputs(s);
- printf(")\n");
- }
-
- skipping = FALSE;
- if (s == NULL)
- s = "";
- for (xp = xbuf; *s != '\0'; s++)
- {
- char c;
-
- /*
- ** Check for non-ordinary (special?) character.
- ** 'q' will be the interpolated quantity.
- */
-
- q = NULL;
- c = *s;
- switch (c)
- {
- case CONDIF: /* see if var set */
- c = *++s;
- skipping = macvalue(c, e) == NULL;
- continue;
-
- case CONDELSE: /* change state of skipping */
- skipping = !skipping;
- continue;
-
- case CONDFI: /* stop skipping */
- skipping = FALSE;
- continue;
-
- case '\001': /* macro interpolation */
- c = *++s;
- q = macvalue(c & 0177, e);
- if (q == NULL)
- continue;
- break;
- }
-
- /*
- ** Interpolate q or output one character
- */
-
- if (skipping || xp >= &xbuf[sizeof xbuf])
- continue;
- if (q == NULL)
- *xp++ = c;
- else
- {
- /* copy to end of q or max space remaining in buf */
- while ((c = *q++) != '\0' && xp < &xbuf[sizeof xbuf - 1])
- {
- if (iscntrl(c) && !isspace(c))
- recurse = TRUE;
- *xp++ = c;
- }
- }
- }
- *xp = '\0';
-
- if (tTd(35, 24))
- {
- printf("expand ==> ");
- xputs(xbuf);
- printf("\n");
- }
-
- /* recurse as appropriate */
- if (recurse)
- {
- expand(xbuf, buf, buflim, e);
- return;
- }
-
- /* copy results out */
- i = buflim - buf - 1;
- if (i > xp - xbuf)
- i = xp - xbuf;
- bcopy(xbuf, buf, i);
- buf[i] = '\0';
- }
- /*
- ** DEFINE -- define a macro.
- **
- ** this would be better done using a #define macro.
- **
- ** Parameters:
- ** n -- the macro name.
- ** v -- the macro value.
- ** e -- the envelope to store the definition in.
- **
- ** Returns:
- ** none.
- **
- ** Side Effects:
- ** e->e_macro[n] is defined.
- **
- ** Notes:
- ** There is one macro for each ASCII character,
- ** although they are not all used. The currently
- ** defined macros are:
- **
- ** $a date in ARPANET format (preferring the Date: line
- ** of the message)
- ** $b the current date (as opposed to the date as found
- ** the message) in ARPANET format
- ** $c hop count
- ** $d (current) date in UNIX (ctime) format
- ** $e the SMTP entry message+
- ** $f raw from address
- ** $g translated from address
- ** $h to host
- ** $i queue id
- ** $j official SMTP hostname, used in messages+
- ** $l UNIX-style from line+
- ** $n name of sendmail ("MAILER-DAEMON" on local
- ** net typically)+
- ** $o delimiters ("operators") for address tokens+
- ** $p my process id in decimal
- ** $q the string that becomes an address -- this is
- ** normally used to combine $g & $x.
- ** $r protocol used to talk to sender
- ** $s sender's host name
- ** $t the current time in seconds since 1/1/1970
- ** $u to user
- ** $v version number of sendmail
- ** $w our host name (if it can be determined)
- ** $x signature (full name) of from person
- ** $y the tty id of our terminal
- ** $z home directory of to person
- **
- ** Macros marked with + must be defined in the
- ** configuration file and are used internally, but
- ** are not set.
- **
- ** There are also some macros that can be used
- ** arbitrarily to make the configuration file
- ** cleaner. In general all upper-case letters
- ** are available.
- */
-
- define(n, v, e)
- char n;
- char *v;
- register ENVELOPE *e;
- {
- if (tTd(35, 9))
- {
- printf("define(%c as ", n);
- xputs(v);
- printf(")\n");
- }
- e->e_macro[n & 0177] = v;
- }
- /*
- ** MACVALUE -- return uninterpreted value of a macro.
- **
- ** Parameters:
- ** n -- the name of the macro.
- **
- ** Returns:
- ** The value of n.
- **
- ** Side Effects:
- ** none.
- */
-
- char *
- macvalue(n, e)
- char n;
- register ENVELOPE *e;
- {
- n &= 0177;
- while (e != NULL)
- {
- register char *p = e->e_macro[n];
-
- if (p != NULL)
- return (p);
- e = e->e_parent;
- }
- return (NULL);
- }
- @
-
-
- 5.7.0.1
- log
- @IDA patches
- @
- text
- @a53 1
- bool quote, inquote, inescape;
- a77 1
- quote = FALSE;
- a93 3
- case QUOTE822:
- quote = TRUE;
- /*FALLTHROUGH*/
- a98 2
- if (quote && !mustquote(q))
- quote = FALSE;
- a107 2
- inquote = FALSE;
- inescape = FALSE;
- a116 12
- if (quote) {
- if (!inquote) {
- *xp++ = '"';
- inquote = TRUE;
- }
- if (c == '"' && !inescape)
- *xp++ = '\\';
- if (c == '\\')
- inescape = !inescape;
- else
- inescape = FALSE;
- }
- a118 4
- if (inescape && xp < &xbuf[sizeof xbuf - 1])
- *xp++ = '\\';
- if (quote && xp < &xbuf[sizeof xbuf - 1])
- *xp++ = '"';
- a176 1
- ** $k our UUCP host name, if different from $w
- a239 3
- if (p == MACNULL)
- /* shadowing null */
- return (NULL);
- a244 31
- }
- /*
- ** MUSTQUOTE -- Check if string contains special RFC-822 chars.
- **
- ** Parameters:
- ** s -- the string to be checked.
- **
- ** Returns:
- ** TRUE if string is in need to be quoted, FALSE otherwise.
- **
- ** Side Effects:
- ** none.
- **
- ** Does this string contain any characters that RFC 822 says
- ** must be quoted?
- ** This is not strictly correct, since we consider ' ' non-special.
- ** Otherwise we'd quote "My Name", which is just too ugly.
- */
- mustquote(s)
- register char *s;
- {
- register int c;
- extern char *index();
-
- while (c = *s++) {
- c &= 0177;
- if (c <= 037 || c == 0177 || /* CTLs */
- index(".()<>@@,;:\\\"[]", c) != NULL)/* 822 specials */
- return TRUE;
- }
- return FALSE;
- @
-
-
- 5.7.0.2
- log
- @Deleted declaration of *index() (breaks when index is a #define strchr)
- from Bruce Lilly. Fixed fencepost error in the third expand() argument.
- @
- text
- @d113 1
- a113 1
- if (skipping || xp >= &xbuf[(sizeof(xbuf)-1)])
- d296 1
- @
-
-
- 5.7.0.3
- log
- @Added static bool declaration to mustquote().
- @
- text
- @a57 1
- static bool mustquote();
- a291 1
- static bool
- @
-
-
- 5.7.0.4
- log
- @ANSIfied.
- @
- text
- @a26 6
- #ifdef __STDC__
- static bool mustquote(const char *);
- #else /* !__STDC__ */
- static bool mustquote();
- #endif /* __STDC__ */
-
- a43 1
- void
- d45 1
- a45 1
- const char *s;
- d47 1
- a47 1
- const char *buflim;
- d57 2
- a230 1
- void
- d295 1
- a295 1
- register const char *s;
- @
-
-
- 5.7.0.5
- log
- @Added RCS ID string
- @
- text
- @a22 1
- static char rcsid[] = "@@(#)$Id$";
- @
-
-
- 5.7.0.6
- log
- @Formatting adjustments.
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: macro.c,v 5.7.0.5 1991/04/05 14:55:15 paul Exp paul $";
- d133 2
- a134 4
- if (quote)
- {
- if (!inquote)
- {
- d306 1
- a306 2
- while (c = *s++)
- {
- @
-
-
- 5.7.0.7
- log
- @Documented $m macro to be to user list as received.
- @
- text
- @d23 1
- a23 1
- static char rcsid[] = "@@(#)$Id: macro.c,v 5.7.0.6 1991/05/18 17:29:02 paul Exp paul $";
- a212 1
- ** $m to user before alias expansion
- @
-